package day1.homeWork;

import java.io.File;
import java.util.Scanner;

public class ShowFile {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入文件路径:");
        File f = null;
        while (true) {
            String path = sc.next();
            f = new File(path);
            if (f.exists()) break;
            else if (f.isFile()) System.out.println("请输入目录地址");
            else System.out.println("路径不存在!");
        }
        print(f);
    }

    public static void print(File f) {
        File[] fs = f.listFiles();
        if (fs != null) {
            for (File file : fs) {
                System.out.println(file.getAbsolutePath());
                print(file);
            }
        } else {
            System.out.println(f.getAbsolutePath());
        }
    }
}
